package com.yf.domain.security;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set;

/**
 * @author chentianwei
 * @date 2023/4/17 13:35
 * @description Role damian
 */

@Getter
@Setter
@ToString
@EqualsAndHashCode(callSuper = false)
@TableName("sys_role")
public class Role implements Serializable {

    @TableId(value = "role_id",type = IdType.AUTO)
    @Schema(name = "主键",hidden = true)
    private Long id;

    @TableField(exist = false)
    private Set<User> users;

    @TableField(exist = false)
    private Set<Menu> menus;

    @TableField(exist = false)
    private Set<Department> departments;

    @TableField(exist = false)
    private Set<Permission> permissions;

    @TableField(value = "data_scope")
    @Schema(name = "数据权限范围")
    private String dataScope;

    @TableField(value = "level")
    @Schema(name = "级别")
    private Integer level = 3;

    @TableField(value = "name")
    @Schema(name = "角色名称")
    private String name;

    @TableField(value = "description")
    @Schema(name = "部门描述")
    private String description;

    @TableField(value = "create_time",insertStrategy = FieldStrategy.DEFAULT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    private Timestamp createTime;

    @TableField(value = "update_time",updateStrategy = FieldStrategy.ALWAYS)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
    private Timestamp updateTime;

    @TableField(value = "create_by",insertStrategy = FieldStrategy.DEFAULT)
    private String createBy;

    @TableField(value = "update_by",updateStrategy = FieldStrategy.ALWAYS)
    private String updateBy;
}
